empty

cd lib\Quest-0.5
Requires Quest
cd ..

only forth definitions

cd data
s" bank0-0.png" Graphic: bank0-0
s" bank0-0.spr" Spriteset: bank0-0spr
cd ..

Texbank: bank0
   bank0-0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
   0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
   0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
   0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
   0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
   0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
   0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
   0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,


Motif: world   lastbody << 2dcamera >>
bank0 Spritebatch: spr-layer0   lastbody world add
bank0 Spritebatch: spr-layer1   lastbody world add

[Motif]
   /Sprite-controller blk property sprctl
   cell blk property direction

: animate  ( sprite# speed. -- )
   sprctl ->speed !   sprctl !sprite ;

: 2dactor  ( spriteset -- )
   sprctl ->spriteset !   ;

Motif: hero
   lastbody <<
      bank0-0spr 2dactor
      11  0.2  animate
      \ 0 bank0-0spr frame[] subimage !
      100 100 x 2v!
      2.0 2.0 sx 2v!
   >>


\ Advance sprite animation 1 frame
: ?frame+
   sprctl ->speed @ if
      sprctl animstep
      sprctl ->frame @  subimage !
   then ;

: frames+   each:[  ?frame+  ;] ;


: screen
   cls
   spr-layer0 frames+
   spr-layer1 frames+
   world render
   ;

: stop
   hero <<  0 sprctl ->speed !  0 vx ! 0 vy !  >> ;

: sword
   direction @ case
      0 of  10 0.3333 animate  0 flip !  endof
      1 of  9 0.3333 animate  0 flip !  endof
      2 of  5 0.3333 animate  1 flip !  endof
      3 of  5 0.3333 animate  0 flip !  endof
   endcase ;

: ctl
   keydown:[
      hero <<
      case
         <z> of  sword  endof
         <up> of -2 vy !  3 0.15 animate  0 direction !  0 flip !  endof
         <down> of 2 vy !  0 0.15 animate  1 direction !  0 flip !  endof
         <left> of -2 vx !  1 flip !  1 0.15 animate  2 direction ! endof
         <right> of 2 vx !  0 flip !  1 0.15 animate  3 direction ! endof
      endcase
      >>
   ;]

   keyup:[
      hero <<
      case
         <up> of stop endof
         <down> of stop endof
         <left> of stop endof
         <right> of stop endof
      endcase
      >>
   ;]

   hero << vx @ x +! vy @ y +! >>
   ;

: init
   640 480 display
   init-all
   ;

: preinit
   init-video-driver
   bank0 init-texbank ;

: ?winfull
   alt? <enter> key? and if fullscreen? not to fullscreen? init then ;

: frame
   ?winfull  ctl  pause  screen  end-frame  ;

0 value exe?

: user-exit?
   alt? <f4> key? and ;

: go
   >seki  begin  frame  user-exit?  <break> key?  or  until
   exe? not if >ide then ;

preinit
init
hero spr-layer0 add
go
